/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services;

import javax.persistence.EntityManager;
import services.interfaces.IOrdersService;
import java.util.Date;
import java.util.List;
import javax.persistence.PersistenceContext;
import javax.validation.ConstraintDeclarationException;
import javax.validation.ConstraintViolationException;
import models.Baskets;
import models.Orders;
import models.Tables;
import models.Users;
import services.interfaces.IUserService;

/**
 *
 * @author serga
 */
public class UsersServiceImpl extends GenericServiceImpl<Users> implements IUserService {

    @PersistenceContext(unitName="ors-ejbPU2")
    private EntityManager em;
    
    public UsersServiceImpl() {
        super(Users.class);
    }
    
    @Override
    public Users getUserById(long id) {
        return (long)em.createNamedQuery("Users.getUserById").setParameter("id_user", id.getId()).getFirstResult();
    }

    @Override
    public List<Users> getUsersByName(String name) {
        return (List<Users>)em.createQuery("Users.getUsersByName").setParameter("id_user", name.getId()).getResultList();
    }

    @Override
    protected EntityManager getEntityManager() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int count() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
